﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ADC.DAL;


namespace ADC.BL
{
    public class ImageFactory
    {
        /// <summary>
        /// Image for programe type = 1
        /// </summary>
        /// <param name="programeID"></param>
        /// <returns></returns>
        public static List<Image> GetAllByProgrameID(int programeID, int type) {
            var db = new dbADCEntities();

            List<Image> listImage = db.Images.Where(g => g.ProgrameID == programeID  && g.ImageType == type).ToList();
            return listImage;
        }

        public static void DeleteByID(int imageID) 
        {
            var db = new dbADCEntities();
            var image = db.Images.Where(g => g.ID == imageID).FirstOrDefault();
            db.DeleteObject(image);
            db.SaveChanges();
        }

        public static void Insert(Image image, int programeID)
        {
            var db = new dbADCEntities();
            image.ProgrameID = programeID;
            db.AddToImages(image);
            db.SaveChanges();
        }
    }
}
